#ifndef __HWICODEC_REQID_H__
#define __HWICODEC_REQID_H__

#include <pthread.h>

typedef struct id_node {
	int			b_using;
	int			b_used;
	int			pos;
} id_node_t;

typedef struct id_prop {
	int			min_id;
	int			max_id;
	int			b_seq;
} id_prop_t;

typedef struct id_elem {
	id_node_t	*p_id_node;
	id_prop_t	id_prop;
} id_elem_t;

typedef struct id_pos {
	int				cur_pos;
	int				pos_distance;
	id_elem_t		id_elem;
	pthread_mutex_t	mutex;
	pthread_cond_t	cond;
} id_pos_t;

typedef struct id_sync {
	int		b_sync;
	int		prev_id;
	int		gopsize;
} id_sync_t;

extern int request_id(id_pos_t *p_id_pos, int req_pos, id_sync_t *sync);
extern void release_id(id_pos_t *p_id_pos, int id);
extern int init_id_pos(id_pos_t *p_id_pos, int pos_distance, int min_id, int max_id, int b_seq);
extern void deinit_id_pos(id_pos_t *p_id_pos);
#endif /* __HWICODEC_REQID_H__ */
